package com.it.service;

import com.it.mapper.SysRoleMapper;
import com.it.pojo.SysRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class SysRoleServiceImpl implements SysRoleService {

	//由spring创建对象并为变量赋值
	@Autowired
	private SysRoleMapper clRoleMapper;

	/**
	 * 1.查询所有图片信息
	 * @return
	 */
	public List<SysRole> findAll(){
		//1.调用roleMapper的findAll方法查询所有图片
		List<SysRole> list = clRoleMapper.findAll();
		return list;
	}
	
	/**
	 * 2.根据id删除图片信息
	 * @param id
	 */
	public int deleteById(String id){
		//1.调用RoleMapper的deleteById方法
		//根据id删除图片信息
		int result = clRoleMapper.deleteById(id);
		return result;
	}
	
	/**
	 * 3.添加图片信息
	 * @param role
	 */
	public int addSysRole(SysRole role){
		int result = clRoleMapper.addSysRole(role);
		return result;
	}
	
	/**
	 * 4.根据id查询图片信息
	 * @param id
	 * @return 
	 */
	public SysRole findById(String id){
		SysRole role = clRoleMapper.findById(id);
		return role;
	}
	
	/**
	 * 5.根据id修改图片信息
	 * @param role
	 */
	public int updateById(SysRole role){
		int result = clRoleMapper.updateById(role);
		return result;
	}
	
}
